#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    QDateTime oldTime = ui->dateTimeEdit->dateTime();
    QDateTime newTime = ui->dateTimeEdit_2->dateTime();

    int days = oldTime.daysTo(newTime);
    int secs = oldTime.secsTo(newTime);
    int hous = (secs/3600)%24;
    if(hous)days--;
    ui->label_3->setText(QString("相差")+QString::number(days)+QString("天")+QString::number(hous)+QString("小时"));

}
